package com.yfbao.horizon.encrypt;

import com.yfbao.horizon.encrypt.utils.AESUtils;
import com.yfbao.horizon.encrypt.utils.DESUtils;

public class Demo {

    public static void main(String[] args) {
        String redis_password = "desoSMdHkQocfcbouWsQ9WEdQ==";
        String redisPassword = decrypt("redis_password", redis_password);
        System.out.println(redisPassword);
    }


    /**
     * seeyon-v8 加密配置信息解密
     * @param key
     * @param value
     * @return
     */
    private static String decrypt(String key, String value) {
        String k = "1qaz@PI#EDC4rfv";
        try {
            if (value.startsWith("encrypt")) {
                return AESUtils.decrypt(value.substring(7), k);
            }
            if (value.startsWith("des")) {
                return DESUtils.decrypt(value.substring(3), k);
            }
        } catch (Exception e) {
            System.out.println("配置中心配置项解密错误,key=" + key + ",value=" + value);
        }
        return value;
    }
}
